package pers.qianyu.module.image.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.qianyu.module.core.comm.HttpResult;
import pers.qianyu.module.core.util.TrieTreeUtil;
import pers.qianyu.module.logging.annotation.ControllerLog;
import pers.qianyu.module.logging.enums.BusinessType;

import java.util.Set;

/**
 * @author mizzle rain
 * @date 2021-03-17 12:19
 */
@Api(tags = "关键词功能相关接口")
@RequestMapping("/image-serv")
@RestController
public class KeywordsController {
    @ApiOperation("根据前缀查询关键词")
    @ControllerLog(businessType = BusinessType.QUERY)
    @GetMapping("/keywords/{prefix}")
    public HttpResult<Set<String>> queryByPrefix(@PathVariable String prefix) {
        Set<String> set = TrieTreeUtil.searchByPrefix(prefix);
        return HttpResult.okWithData(set);
    }
}
